//
//  InformationListTableviewCell.m
//  TeamInformatization
//
//  Created by 李光磊 on 2019/4/2.
//  Copyright © 2019 SPIC. All rights reserved.
//

#import "InformationListTableviewCell.h"

@interface InformationListTableviewCell ()

@property (nonatomic, strong) NSMutableArray *imageArr;
@property (nonatomic, strong) NSMutableArray *nameArr;
@property (nonatomic, strong) NSMutableArray *xArr;

@end

@implementation InformationListTableviewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupUI];
    }
    return self;
}
-(NSMutableArray *)imageArr {
    if (!_imageArr) {
        _imageArr = [NSMutableArray arrayWithObjects:@"分组 11",@"分组 12",@"分组 13", nil];
    }
    return _imageArr;
}
-(NSMutableArray *)nameArr {
    if (!_nameArr) {
        _nameArr = [NSMutableArray arrayWithObjects:@"格式：",@"在线学习：",@"在线培训：", nil];
    }
    return _nameArr;
}
-(NSMutableArray *)xArr {
    if (!_xArr) {
        _xArr = [NSMutableArray arrayWithObjects:@107,@180,@285, nil];
    }
    return _xArr;
}
-(void)setupUI {
    
    _imagev = [[UIImageView alloc] init];
//    _imagev.image = [UIImage imageNamed:@""];
    _imagev.backgroundColor = [UIColor orangeColor];
    [self addSubview:_imagev];
    [_imagev mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(16);
        make.left.mas_equalTo(15);
        make.size.mas_equalTo(CGSizeMake(82, 82));
    }];
    
    _titleLab = [[UILabel alloc] init];
    _titleLab.text = @"内蒙古公司安全生产基础巩固年专项检查实施方案";
    [self addSubview:_titleLab];
    
    NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"内蒙古公司安全生产基础巩固年专项检查实施方案"attributes: @{NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Medium" size:15],NSForegroundColorAttributeName: [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0]}];
    
    _titleLab.attributedText = string;
    _titleLab.textAlignment = NSTextAlignmentLeft;
    _titleLab.numberOfLines = 0;
    _titleLab.lineBreakMode = NSLineBreakByWordWrapping;
    [_titleLab sizeToFit];
    [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(14);
        make.left.mas_equalTo(107);
        make.right.mas_equalTo(-5);
        make.height.mas_equalTo(42);
    }];
    
    _subTitleLab = [[UILabel alloc] init];
    _subTitleLab.text= @"部署2019年工作重点部署2019年工作重点";
    [self addSubview:_subTitleLab];
    
    NSMutableAttributedString *string2 = [[NSMutableAttributedString alloc] initWithString:@"部署2019年工作重点部署2019年工作重点" attributes: @{NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Regular" size: 12],NSForegroundColorAttributeName: [UIColor colorWithRed:138/255.0 green:138/255.0 blue:138/255.0 alpha:1.0]}];
    
    _subTitleLab.attributedText = string2;
    _subTitleLab.textAlignment = NSTextAlignmentLeft;
    _subTitleLab.numberOfLines = 0;
    _subTitleLab.lineBreakMode = NSLineBreakByWordWrapping;
    [_subTitleLab sizeToFit];
    [_subTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(63);
        make.left.mas_equalTo(107);
        make.right.mas_equalTo(-44);
        make.height.mas_equalTo(17);
    }];
    
    for (int i = 0; i < 3; i++) {
        _subBtn = [[UIButton alloc] init];
        CGFloat xfloat = [self.xArr[i] floatValue];
        _subBtn.frame = CGRectMake(xfloat, 90, (kScreenWidth-107)/3, 17);
        [_subBtn setTitle:self.nameArr[i] forState:UIControlStateNormal];
        [_subBtn setTitleColor:kUIColorHex(0x576B95) forState:UIControlStateNormal];
        _subBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        _subBtn.titleLabel.font = kFont(PFSCRegular, 12);
        [_subBtn setImage:[UIImage imageNamed:self.imageArr[i]] forState:UIControlStateNormal];
        [_subBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, -_subBtn.imageView.frame.size.width, 0, _subBtn.imageView.frame.size.width)];
        [_subBtn setImageEdgeInsets:UIEdgeInsetsMake(0, _subBtn.titleLabel.bounds.size.width, 0, - _subBtn.titleLabel.bounds.size.width)];
        _subBtn.tag = 100 + i;
        [_subBtn addTarget:self action:@selector(subBtn:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_subBtn];
    }
}
// 赋值
- (void)setShowViewCellWithData:(InformationData *)data
{
    
}
- (void)subBtn:(UIButton *)sender {
    NSLog(@"%ld", (long)sender.tag);
}
@end
